﻿@model CustomerModel
@using Nop.Core.Domain.Orders;
@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.Id)

<div id="customer-edit">
    <ul>
        <li @Html.RenderSelectedTabIndex(0, GetSelectedTabIndex())>
            @T("Admin.Customers.Customers.Info")
        </li>
        <li @Html.RenderSelectedTabIndex(1, GetSelectedTabIndex())>
            @T("Admin.Customers.Customers.CustomerRoles")
        </li>
        @if (Model.Id > 0)
        {
            <li @Html.RenderSelectedTabIndex(2, GetSelectedTabIndex())>
                @T("Admin.Customers.Customers.Orders")
            </li>
            <li @Html.RenderSelectedTabIndex(3, GetSelectedTabIndex())>
                @T("Admin.Customers.Customers.Addresses")
            </li>
            <li @Html.RenderSelectedTabIndex(4, GetSelectedTabIndex())>
                @T("Admin.Customers.Customers.CurrentShoppingCart")
            </li>
            <li @Html.RenderSelectedTabIndex(5, GetSelectedTabIndex())>
                @T("Admin.Customers.Customers.CurrentWishlist")
            </li>
            <li @Html.RenderSelectedTabIndex(6, GetSelectedTabIndex())>
                @T("Admin.Customers.Customers.ActivityLog")
            </li>
            <li @Html.RenderSelectedTabIndex(7, GetSelectedTabIndex())>
                @T("Admin.Customers.Customers.Impersonate")
            </li>
        }
        @if (Model.DisplayRewardPointsHistory)
        {
            <li>
                @T("Admin.Customers.Customers.RewardPoints")
            </li>
        }
    </ul>
    <div>
        @TabInfo()
    </div>
    <div>
        @TabCustomerRoles()
    </div>
    @if (Model.Id > 0)
    {
        <div>
            @TabOrders()
        </div>
        <div>
            @TabAddresses()
        </div>
        <div>
            @TabCurrentShoppingCart()
        </div>
        <div>
            @TabCurrentWishlist()
        </div>
        <div>
            @TabActivityLog()
        </div>
        <div>
            @TabImpersonate()
        </div>
    }
    @if (Model.DisplayRewardPointsHistory)
    {
       <div>
            @TabRewardPoints()
        </div>
    }
</div>
<script>
    $(document).ready(function() {
        $("#customer-edit").kendoTabStrip({
            animation:  {
                open: {
                    effects: "fadeIn"
                }
            },
            select: tabstrip_on_tab_select
        });
    });
</script>

@{
    //custom tabs
    var eventMessage = new AdminTabStripCreated(this.Html, "customer-edit");
    EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
    foreach (var eventBlock in eventMessage.BlocksToRender)
    {
        @eventBlock
    }
}

@*save selected tab index*@
<input type="hidden" id="selected-tab-index" name="selected-tab-index" value="@(GetSelectedTabIndex())">

@helper TabInfo()
    { 
        if (Model.CountryEnabled && Model.StateProvinceEnabled)
        {
    <script type="text/javascript">
        $(document).ready(function() {
            $("#@Html.FieldIdFor(model => model.CountryId)").change(function() {
                var selectedItem = $(this).val();
                var ddlStates = $("#@Html.FieldIdFor(model => model.StateProvinceId)");
                $.ajax({
                    cache: false,
                    type: "GET",
                    url: "@(Url.Action("GetStatesByCountryId", "Country"))",
                    data: { "countryId": selectedItem, "addEmptyStateIfRequired": "true" },
                    success: function(data) {
                        ddlStates.html('');
                        $.each(data, function(id, option) {
                            ddlStates.append($('<option></option>').val(option.id).html(option.name));
                        });
                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        alert('Failed to retrieve states.');
                    }
                });
            });
        });
    </script>
        }
    <table class="adminContent customer-info-tab">
        @if (Model.UsernamesEnabled)
        {
            if (Model.Id == 0 || Model.AllowUsersToChangeUsernames)
            {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.Username):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.Username)
                    @Html.ValidationMessageFor(model => model.Username)
                </td>
            </tr>
            }
            else
            {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.Username):
                </td>
                <td class="adminData">
                    @Model.Username
                    @Html.HiddenFor(model => model.Username)
                </td>
            </tr>
            }
        }
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Email):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.Email)
                @Html.ValidationMessageFor(model => model.Email)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Password):
            </td>
            <td class="adminData">
                @Html.TextBoxFor(model => model.Password, new { autocomplete = "off", @class = "text-box single-line" })
                @Html.ValidationMessageFor(model => model.Password)
                @if (Model.Id > 0)
                {
                    <input type="submit" name="changepassword" class="k-button" value="@T("Admin.Customers.Customers.Fields.Password.Change")" />
                }
            </td>
        </tr>
        @if (Model.Id > 0 && Model.AssociatedExternalAuthRecords.Count > 0)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.AssociatedExternalAuthRecords):
                </td>
                <td class="adminData">

                    <div id="externalauthrecords-grid"></div>

                    <script>

                        //local datasource
                        var externalauthrecords = [
                            @for (int i = 0; i < Model.AssociatedExternalAuthRecords.Count; i++)
                            {
                                var aear = Model.AssociatedExternalAuthRecords[i];
                                <text>
    {
        AuthMethodName: "@(Html.Raw(HttpUtility.JavaScriptStringEncode(aear.AuthMethodName)))",
        Email: "@(Html.Raw(HttpUtility.JavaScriptStringEncode(aear.Email)))",
    ExternalIdentifier: "@(Html.Raw(HttpUtility.JavaScriptStringEncode(aear.ExternalIdentifier)))"
    }
</text>
                                if (i != Model.AssociatedExternalAuthRecords.Count - 1)
                                {
                                    <text>,</text>
                                }
                            }
                        ];

                        $(document).ready(function () {
                            $("#externalauthrecords-grid").kendoGrid({
                                dataSource: {
                                    data: externalauthrecords,
                                    schema: {
                                        model: {
                                            fields: {
                                                AuthMethodName: { type: "string" },
                                                Email: { type: "string" },
                                                ExternalIdentifier: { type: "string" }
                                            }
                                        }
                                    },
                                    error: function (e) {
                                        display_kendoui_grid_error(e);
                                        // Cancel the changes
                                        this.cancelChanges();
                                    }
                                },
                                pageable: {
                                    refresh: true,
                                    numeric: false,
                                    previousNext: false,
                                    info: false
                                },
                                scrollable: false,
                                columns: [
                                    {
                                        field: "AuthMethodName",
                                        title: "@T("Admin.Customers.Customers.AssociatedExternalAuth.Fields.AuthMethodName")",
                                        width: 100
                                    }, {
                                        field: "Email",
                                        title: "@T("Admin.Customers.Customers.AssociatedExternalAuth.Fields.Email")",
                                        width: 100
                                    },{
                                        field: "ExternalIdentifier",
                                        title: "@T("Admin.Customers.Customers.AssociatedExternalAuth.Fields.ExternalIdentifier")",
                                        width: 300
                                    }
                                ]
                            });
                        });

                    </script>
                </td>
            </tr>
        }
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.VendorId):
            </td>
            <td class="adminData">
                @Html.DropDownListFor(model => model.VendorId, Model.AvailableVendors)
                @Html.ValidationMessageFor(model => model.VendorId)
                <em>@T("Admin.Customers.Customers.VendorShouldBeInVendorsRole")</em>
            </td>
        </tr>
        @if (Model.GenderEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.Gender):
                </td>
                <td class="adminData">
                    <div class="gender">
                        @Html.RadioButton("Gender", "M", (Model.Gender == "M"), new { id = "Gender_Male" })
                    <label class="forcheckbox" for="Gender_Male">@T("Admin.Customers.Customers.Fields.Gender.Male")</label>
                        </div>
                    <div class="gender">
                        @Html.RadioButton("Gender", "F", (Model.Gender == "F"), new { id = "Gender_Female" })
                        <label class="forcheckbox" for="Gender_Female">@T("Admin.Customers.Customers.Fields.Gender.Female")</label>
                    </div>
                </td>
            </tr>
        }
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.FirstName):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.FirstName)
                @Html.ValidationMessageFor(model => model.FirstName)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.LastName):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.LastName)
                @Html.ValidationMessageFor(model => model.LastName)
            </td>
        </tr>
        @if (Model.DateOfBirthEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.DateOfBirth):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.DateOfBirth)
                    @Html.ValidationMessageFor(model => model.DateOfBirth)
                </td>
            </tr>
        }
        @if (Model.CompanyEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.Company):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.Company)
                    @Html.ValidationMessageFor(model => model.Company)
                </td>
            </tr>
        }
        @if (Model.StreetAddressEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.StreetAddress):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.StreetAddress)
                    @Html.ValidationMessageFor(model => model.StreetAddress)
                </td>
            </tr>
        }
        @if (Model.StreetAddress2Enabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.StreetAddress2):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.StreetAddress2)
                    @Html.ValidationMessageFor(model => model.StreetAddress2)
                </td>
            </tr>
        }
        @if (Model.ZipPostalCodeEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.ZipPostalCode):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.ZipPostalCode)
                    @Html.ValidationMessageFor(model => model.ZipPostalCode)
                </td>
            </tr>
        }
        @if (Model.CityEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.City):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.City)
                    @Html.ValidationMessageFor(model => model.City)
                </td>
            </tr>
        }
        @if (Model.CountryEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.CountryId):
                </td>
                <td class="adminData">
                    @Html.DropDownList("CountryId", Model.AvailableCountries)
                </td>
            </tr>
        }
        @if (Model.CountryEnabled && Model.StateProvinceEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.StateProvinceId):
                </td>
                <td class="adminData">
                    @Html.DropDownList("StateProvinceId", Model.AvailableStates)
                </td>
            </tr>
        }
        @if (Model.PhoneEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.Phone):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.Phone)
                    @Html.ValidationMessageFor(model => model.Phone)
                </td>
            </tr>
        }
        @if (Model.FaxEnabled)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.Fax):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.Fax)
                    @Html.ValidationMessageFor(model => model.Fax)
                </td>
            </tr>
        }
        @if (Model.CustomerAttributes.Count > 0)
        {
            @Html.Partial("_CustomerAttributes", Model.CustomerAttributes)
        }
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.AdminComment):
            </td>
            <td class="adminData">
                @Html.TextAreaFor(model => model.AdminComment, new { style = "Width: 250px; Height: 150px;" })
                @Html.ValidationMessageFor(model => model.AdminComment)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.IsTaxExempt):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.IsTaxExempt)
                @Html.ValidationMessageFor(model => model.IsTaxExempt)
            </td>
        </tr>
        @if (Model.AllowCustomersToSetTimeZone)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.TimeZoneId):
                </td>
                <td class="adminData">
                    @Html.DropDownList("TimeZoneId", Model.AvailableTimeZones)
                    @Html.ValidationMessageFor(model => model.TimeZoneId)
                </td>
            </tr>
        }
        @if (Model.AffiliateId.HasValue && Model.AffiliateId.Value > 0)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.AffiliateId):
                </td>
                <td class="adminData">
                    <a href="@Url.Action("Edit", "Affiliate", new { id = Model.AffiliateId.Value })">@Model.AffiliateId.Value
                        - @T("Admin.Common.View")</a>
                </td>
            </tr>
        }
        @if (Model.DisplayVatNumber)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.VatNumber):
                </td>
                <td class="adminData">
                    @Html.EditorFor(model => model.VatNumber)
                    (@string.Format(T("Admin.Customers.Customers.Fields.VatNumberStatus").Text, Model.VatNumberStatusNote))
                    <input type="submit" name="markVatNumberAsValid" class="k-button" value="@T("Admin.Customers.Customers.Fields.VatNumber.MarkAsValid")" />
                    <input type="submit" name="markVatNumberAsInvalid" class="k-button" value="@T("Admin.Customers.Customers.Fields.VatNumber.MarkAsInvalid")" />
                    @Html.ValidationMessageFor(model => model.VatNumber)
                </td>
            </tr>
        }
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Active):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.Active)
                @Html.ValidationMessageFor(model => model.Active)
            </td>
        </tr>
        @if (Model.Id > 0)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.LastIpAddress):
                </td>
                <td class="adminData">
                    @Html.DisplayFor(model => model.LastIpAddress)
                </td>
            </tr>
        }
        @if (Model.Id > 0)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.CreatedOn):
                </td>
                <td class="adminData">
                    @Html.DisplayFor(model => model.CreatedOn)
                </td>
            </tr>
        }
        @if (Model.Id > 0)
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.LastActivityDate):
                </td>
                <td class="adminData">
                    @Html.DisplayFor(model => model.LastActivityDate)
                </td>
            </tr>
        }
        @if (Model.Id > 0 && !String.IsNullOrEmpty(Model.LastVisitedPage))
        {
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.LastVisitedPage):
                </td>
                <td class="adminData">
                    @Html.DisplayFor(model => model.LastVisitedPage)
                </td>
            </tr>
        }
    </table>
}
@helper TabCustomerRoles()
    {
        if (Model.AvailableCustomerRoles != null && Model.AvailableCustomerRoles.Count > 0)
        {
            foreach (var customerRole in Model.AvailableCustomerRoles)
            {
    <input type="checkbox" name="SelectedCustomerRoleIds" value="@customerRole.Id"
                @if (Model.SelectedCustomerRoleIds != null && Model.SelectedCustomerRoleIds.Contains(customerRole.Id))
                {
                    <text> checked="checked"</text>
                }
                />@customerRole.Name
    <br />
            }
        }
        else
        {
    @T("Admin.Customers.Customers.Fields.CustomerRoles.NoRoles")
        }
}
@helper TabOrders()
    {
    var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
    var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    <div id="order-grid"></div>
        
    <script>
        $(document).ready(function () {
            $("#order-grid").kendoGrid({
                dataSource: {
                    type: "json",
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("OrderList", "Customer", new { customerId = Model.Id }))",
                            type: "POST",
                            dataType: "json"
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors"
                    },
                    error: function(e) {
                        display_kendoui_grid_error(e);
                        // Cancel the changes
                        this.cancelChanges();
                    },
                    pageSize: @(defaultGridPageSize),
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    pageSizes: [@(gridPageSizes)]
                },
                editable: {
                    confirmation: false,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "Id",
                    title: "@T("Admin.Customers.Customers.Orders.ID")",
                    width: 50
                }, {
                    field: "OrderTotal",
                    title: "@T("Admin.Customers.Customers.Orders.OrderTotal")",
                    width: 200
                }, {
                    field: "OrderStatus",
                    title: "@T("Admin.Customers.Customers.Orders.OrderStatus")",
                    width: 200
                }, {
                    field: "PaymentStatus",
                    title: "@T("Admin.Customers.Customers.Orders.PaymentStatus")",
                    width: 200
                }, {
                    field: "ShippingStatus",
                    title: "@T("Admin.Customers.Customers.Orders.ShippingStatus")",
                    width: 200
                }, {
                    field: "StoreName",
                    title: "@T("Admin.Customers.Customers.Orders.Store")",
                    width: 200
                }, {
                    field: "CreatedOn",
                    title: "@T("Admin.System.Log.Fields.CreatedOn")",
                    width: 200,
                    type: "date",
                    format: "{0:G}"
                }, {
                    field: "Id",
                    title: "@T("Admin.Common.View")",
                    width: 100,
                    template: '<a href="@Url.Content("~/Admin/Order/Edit/")#=Id#">@T("Admin.Common.View")</a>'
                }]
            });
        });
    </script>
}
@helper TabRewardPoints()
    {
    <div id="customer-rewardpoints-grid"></div>
        
    <script>
        $(document).ready(function () {
            $("#customer-rewardpoints-grid").kendoGrid({
                dataSource: {
                    type: "json",
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("RewardPointsHistorySelect", "Customer", new { customerId = Model.Id }))",
                            type: "POST",
                            dataType: "json"
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors"
                    },
                    error: function(e) {
                        display_kendoui_grid_error(e);
                        // Cancel the changes
                        this.cancelChanges();
                    },
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    numeric: false,
                    previousNext: false,
                    info: false
                },
                editable: {
                    confirmation: false,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "Points",
                    title: "@T("Admin.Customers.Customers.RewardPoints.Fields.Points")"
                }, {
                    field: "PointsBalance",
                    title: "@T("Admin.Customers.Customers.RewardPoints.Fields.PointsBalance")"
                },{
                    field: "Message",
                    title: "@T("Admin.Customers.Customers.RewardPoints.Fields.Message")"
                },{
                    field: "CreatedOn",
                    title: "@T("Admin.Promotions.Campaigns.Fields.CreatedOn")",
                    width: 200,
                    type: "date",
                    format: "{0:G}"
                }]
            });
        });
    </script>
    <p>
        <strong>
            @T("Admin.Customers.Customers.RewardPoints.AddTitle")
        </strong>
    </p>
    <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.AddRewardPointsValue)
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.AddRewardPointsValue)
                @Html.ValidationMessageFor(model => model.AddRewardPointsValue)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.AddRewardPointsMessage)
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.AddRewardPointsMessage)
                @Html.ValidationMessageFor(model => model.AddRewardPointsMessage)
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left">
                <input type="button" id="addRewardPoints" class="k-button" value="@T("Admin.Customers.Customers.RewardPoints.AddButton")" />
            </td>
        </tr>
    </table>
    
    <script type="text/javascript">
        $(document).ready(function () {
            $('#addRewardPoints').click(function () {
                var rewardPointsValue = $("#@Html.FieldIdFor(model => model.AddRewardPointsValue)").val();
                var rewardPointsMessage = $("#@Html.FieldIdFor(model => model.AddRewardPointsMessage)").val();
                $('#addRewardPoints').attr('disabled', true);
                $.ajax({
                    cache:false,
                    type: "POST",
                    url: "@(Url.Action("RewardPointsHistoryAdd", "Customer"))",
                    data: { "addRewardPointsValue": rewardPointsValue, "addRewardPointsMessage": rewardPointsMessage, "customerId": @Model.Id},
                    success: function (data) {
                        var rewardPointsGrid = $("#customer-rewardpoints-grid").data('kendoGrid');
                        rewardPointsGrid.dataSource.read();
                         $('#addRewardPoints').attr('disabled', false);
                    },
                    error:function (xhr, ajaxOptions, thrownError){
                        alert('Failed to add reward points.');
                        $('#addRewardPoints').attr('disabled', false);
                    }  
                });
            });
        });
    </script>
}
@helper TabAddresses()
    {
    <div id="customer-addresses-grid"></div>

    <script>
        $(document).ready(function () {
            $("#customer-addresses-grid").kendoGrid({
                dataSource: {
                    type: "json",
                    transport: {
                        read: {
                            url: "@Html.Raw(Url.Action("AddressesSelect", "Customer", new { customerId = Model.Id }))",
                            type: "POST",
                            dataType: "json"
                        },
                        destroy: {
                            url: "@Html.Raw(Url.Action("AddressDelete", "Customer", new { customerId = Model.Id }))",
                            type: "POST",
                            dataType: "json"
                        }
                    },
                    schema: {
                        data: "Data",
                        total: "Total",
                        errors: "Errors",
                        model: {
                            id: "Id"
                        }
                    },
                    error: function(e) {
                        display_kendoui_grid_error(e);
                        // Cancel the changes
                        this.cancelChanges();
                    },
                    serverPaging: true,
                    serverFiltering: true,
                    serverSorting: true
                },
                pageable: {
                    refresh: true,
                    numeric: false,
                    previousNext: false,
                    info: false
                },
                editable: {
                    confirmation: false,
                    mode: "inline"
                },
                scrollable: false,
                columns: [{
                    field: "FirstName",
                    title: "@T("Admin.Address.Fields.FirstName")"
                }, {
                    field: "LastName",
                    title: "@T("Admin.Address.Fields.LastName")"
                }, {
                    field: "Email",
                    title: "@T("Admin.Address.Fields.Email")"
                }, {
                    field: "PhoneNumber",
                    title: "@T("Admin.Address.Fields.PhoneNumber")"
                }, {
                    field: "FaxNumber",
                    title: "@T("Admin.Address.Fields.FaxNumber")"
                }, {
                    field: "AddressHtml",
                    title: "@T("Admin.Address")",
                    encoded: false
                }, {
                    field: "Id",
                    title: "@T("Admin.Common.Edit")",
                    width: 100,
                    template: '<a href="@Url.Content("~/Admin/Customer/AddressEdit?customerId=")@Model.Id&addressid=#=Id#">@T("Admin.Common.Edit")</a>'
                }, {
                    command: { name: "destroy", text: "@T("Admin.Common.Delete")" }, 
                    title: "@T("Admin.Common.Delete")",
                    width: 100
                }]
            });
        });
    </script>
    <p>
        <strong>
            <input type="button" class="k-button" onclick="location.href='@Url.Action("AddressCreate", new { customerId = Model.Id })'" value='@T("Admin.Customers.Customers.Addresses.AddButton")' />
        </strong>
    </p>
}
@helper TabCurrentShoppingCart()
    {
    <table class="adminContent">
        <tr>
            <td>
                <div id="currentshoppingcart-grid"></div>

                <script>
                    $(document).ready(function () {
                        $("#currentshoppingcart-grid").kendoGrid({
                            dataSource: {
                                type: "json",
                                transport: {
                                    read: {
                                        url: "@Html.Raw(Url.Action("GetCartList", "Customer", new { customerId = Model.Id, cartTypeId = (int)ShoppingCartType.ShoppingCart }))",
                                        type: "POST",
                                        dataType: "json"
                                    }
                                },
                                schema: {
                                    data: "Data",
                                    total: "Total",
                                    errors: "Errors"
                                },
                                error: function(e) {
                                    display_kendoui_grid_error(e);
                                    // Cancel the changes
                                    this.cancelChanges();
                                },
                                serverPaging: true,
                                serverFiltering: true,
                                serverSorting: true
                            },
                            pageable: {
                                refresh: true,
                                numeric: false,
                                previousNext: false,
                                info: false
                            },
                            editable: {
                                confirmation: false,
                                mode: "inline"
                            },
                            scrollable: false,
                            columns: [{
                                field: "ProductName",
                                title: "@T("Admin.CurrentCarts.Product")",
                                width:500,
                                template: '<a href="@Url.Content("~/Admin/Product/Edit/")#=ProductId#">#=ProductName#</a>'
                            }, {
                                field: "Quantity",
                                title: "@T("Admin.CurrentCarts.Quantity")",
                                width:200
                            },{
                                field: "UnitPrice",
                                title: "@T("Admin.CurrentCarts.UnitPrice")",
                                width:200
                            },{
                                field: "Total",
                                title: "@T("Admin.CurrentCarts.Total")",
                                width:200
                            },{
                                field: "Store",
                                title: "@T("Admin.CurrentCarts.Store")",
                                width:200
                            },{
                                field: "UpdatedOn",
                                title: "@T("Admin.CurrentCarts.UpdatedOn")",
                                width: 200,
                                type: "date",
                                format: "{0:G}"
                            }]
                        });
                    });
                </script>
            </td>
        </tr>
    </table>
}
@helper TabCurrentWishlist()
    {
    <table class="adminContent">
        <tr>
            <td>
                <div id="currentwishlist-grid"></div>

                <script>
                    $(document).ready(function () {
                        $("#currentwishlist-grid").kendoGrid({
                            dataSource: {
                                type: "json",
                                transport: {
                                    read: {
                                        url: "@Html.Raw(Url.Action("GetCartList", "Customer", new { customerId = Model.Id, cartTypeId = (int)ShoppingCartType.Wishlist }))",
                                        type: "POST",
                                        dataType: "json"
                                    }
                                },
                                schema: {
                                    data: "Data",
                                    total: "Total",
                                    errors: "Errors"
                                },
                                error: function(e) {
                                    display_kendoui_grid_error(e);
                                    // Cancel the changes
                                    this.cancelChanges();
                                },
                                serverPaging: true,
                                serverFiltering: true,
                                serverSorting: true
                            },
                            pageable: {
                                refresh: true,
                                numeric: false,
                                previousNext: false,
                                info: false
                            },
                            editable: {
                                confirmation: false,
                                mode: "inline"
                            },
                            scrollable: false,
                            columns: [{
                                field: "ProductName",
                                title: "@T("Admin.CurrentCarts.Product")",
                                width:500,
                                template: '<a href="@Url.Content("~/Admin/Product/Edit/")#=ProductId#">#=ProductName#</a>'
                            }, {
                                field: "Quantity",
                                title: "@T("Admin.CurrentCarts.Quantity")",
                                width:200
                            },{
                                field: "UnitPrice",
                                title: "@T("Admin.CurrentCarts.UnitPrice")",
                                width:200
                            },{
                                field: "Total",
                                title: "@T("Admin.CurrentCarts.Total")",
                                width:200
                            },{
                                field: "Store",
                                title: "@T("Admin.CurrentCarts.Store")",
                                width:200
                            },{
                                field: "UpdatedOn",
                                title: "@T("Admin.CurrentCarts.UpdatedOn")",
                                width: 200,
                                type: "date",
                                format: "{0:G}"
                            }]
                        });
                    });
                </script>
            </td>
        </tr>
    </table>
}
@helper TabActivityLog()
    {
        var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
        var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;

    <table class="adminContent">
        <tr>
            <td>
                <div id="activitylog-grid"></div>

                <script>
                    $(document).ready(function () {
                        $("#activitylog-grid").kendoGrid({
                            dataSource: {
                                type: "json",
                                transport: {
                                    read: {
                                        url: "@Html.Raw(Url.Action("ListActivityLog", "Customer", new { customerId = Model.Id }))",
                                        type: "POST",
                                        dataType: "json"
                                    }
                                },
                                schema: {
                                    data: "Data",
                                    total: "Total",
                                    errors: "Errors"
                                },
                                error: function(e) {
                                    display_kendoui_grid_error(e);
                                    // Cancel the changes
                                    this.cancelChanges();
                                },
                                pageSize: @(defaultGridPageSize),
                                serverPaging: true,
                                serverFiltering: true,
                                serverSorting: true
                            },
                            pageable: {
                                refresh: true,
                                pageSizes: [@(gridPageSizes)]
                            },
                            editable: {
                                confirmation: false,
                                mode: "inline"
                            },
                            scrollable: false,
                            columns: [{
                                field: "ActivityLogTypeName",
                                title: "@T("Admin.Customers.Customers.ActivityLog.ActivityLogType")",
                                width: 300,
                            }, {
                                field: "Comment",
                                title: "@T("Admin.Customers.Customers.ActivityLog.Comment")"
                            }, {
                                field: "CreatedOn",
                                title: "@T("Admin.Customers.Customers.ActivityLog.CreatedOn")",
                                width: 200,
                                type: "date",
                                format: "{0:G}"
                            }]
                        });
                    });
                </script>
            </td>
        </tr>
    </table>
}
@helper TabImpersonate()
    {
    <table class="adminContent">
        <tr>
            <td>
                @T("Admin.Customers.Customers.Impersonate.Description1")
                <br />
                @T("Admin.Customers.Customers.Impersonate.Description2")
                <br />
                <br />
                <input type="submit" name="impersonate" class="k-button" value="@T("Admin.Customers.Customers.Impersonate.Button")" />
            </td>
        </tr>
    </table>
}
